#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int getMaximumGenerated(int n) {
        if (!n)
            return 0;
        vector<int> v1;
        v1.push_back(0);
        v1.push_back(1);
        int flag = 1;
        for (int i = 2; v1.size() <= n;)
        {
            if (flag)
            {
                v1.push_back(v1[i - 1]);
                flag = 0;
            }
            else
            {
                v1.push_back(v1[i] + v1[i - 1]);
                ++i;
                flag = 1;
            }
        }
        sort(v1.begin(), v1.end(), greater<int>());
        return v1[0];
    }
};